home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 276-300 / 299 / rxil / src / console.c < prev    next >
C/C++ Source or Header  |  1995-03-14  |  2KB  |  135 lines

  1. /* console.c */
  2.  
  3. /*        Copyright © 1989 by Donald T. Meyer, Stormgate Software
  4.  *        All Rights Reserved
  5.  */
  6.  
  7.  
  8.  
  9. #include "rxil.h"
  10.  
  11. #include <libraries/dos.h>
  12.  
  13. #include <proto/dos.h>
  14.  
  15.  
  16.  
  17. /* NAME
  18.  *        RxilOpenConsole
  19.  *
  20.  * SYNOPSIS
  21.  *        RxilOpenConsole( console, rexxmsg );
  22.  *
  23.  *        char *console;
  24.  *        struct RexxMsg *rexxmsg;
  25.  *
  26.  * FUNCTION
  27.  *        This will open an AmigaDOS stream as specified by the console
  28.  *        string.  The filehandle is then placed in the rm_Stdin and
  29.  *        rm_Stdout fields of the RexxMsg.
  30.  *
  31.  * INPUTS
  32.  *        console = a string which defines the console stream to be opened.
  33.  *            This will normally be something like "CON:0/0/400/100/".
  34.  *        rexxmsg = pointer to the RexxMsg that the AmigaDOS file handles
  35.  *            are to be set into.
  36.  *
  37.  * RESULT
  38.  *        None
  39.  *
  40.  * SIDES
  41.  *
  42.  * HISTORY
  43.  *        01-Aug-89    Creation.
  44.  *
  45.  * BUGS
  46.  *
  47.  * SEE ALSO
  48.  *        RxilCloseConsole()
  49.  */
  50.  
  51. void RxilOpenConsole( char *console, struct RexxMsg *rexxmsg )
  52. {
  53.     struct FileHandle *fh;
  54.  
  55.  
  56.     fh = (struct Filehandle *)Open( console, MODE_NEWFILE );
  57.     if( fh == NULL )
  58.     {
  59.         return;
  60.     }
  61.  
  62.     rexxmsg->rm_Stdin = (LONG)fh;
  63.     rexxmsg->rm_Stdout = (LONG)fh;
  64. }
  65.  
  66.  
  67.  
  68. /* NAME
  69.  *        RxilCloseConsole
  70.  *
  71.  * SYNOPSIS
  72.  *        RxilCloseConsole( rexxmsg )
  73.  *
  74.  *        struct RexxMsg *rexxmsg;
  75.  *
  76.  * FUNCTION
  77.  *        This will close the AmigaDOS file handles contained in the
  78.  *        rm_Stdin and rm_Stdout fields of the RexxMsg.  If the handles
  79.  *        are the same, only one close is performed.
  80.  *        This clears the fields.  If the fields are NULL, then no action
  81.  *        is taken.
  82.  *        This function supports the rm_Stdin and rm_Stdout being seperate
  83.  *        handles, even though it's complimentary function,
  84.  *        RxilOpenConsole() does not do this.
  85.  *
  86.  * INPUTS
  87.  *        rexxmsg = pointer to the RexxMsg whose IO streams are to be
  88.  *            closed.
  89.  *
  90.  * RESULT
  91.  *        None
  92.  *
  93.  * SIDES
  94.  *
  95.  * HISTORY
  96.  *        01-Aug-89    Creation.
  97.  *
  98.  * BUGS
  99.  *
  100.  * SEE ALSO
  101.  *        RxilOpenConsole()
  102.  */
  103.  
  104. void RxilCloseConsole( struct RexxMsg *rexxmsg )
  105. {
  106.     if(  ( rexxmsg->rm_Stdin == NULL ) && ( rexxmsg->rm_Stdout == NULL )  )
  107.     {
  108.         /* Nothing to close */
  109.         return;
  110.     }
  111.  
  112.  
  113.     /* There is something to close */
  114.  
  115.     if( rexxmsg->rm_Stdin == rexxmsg->rm_Stdout )
  116.     {
  117.         /* File handles are the same, only close once! */
  118.         rexxmsg->rm_Stdout = NULL;
  119.     }
  120.  
  121.     /* Close file handles individualy */
  122.     if( rexxmsg->rm_Stdin )
  123.     {
  124.         Close( rexxmsg->rm_Stdin );
  125.         rexxmsg->rm_Stdin = NULL;
  126.     }
  127.  
  128.     if( rexxmsg->rm_Stdout )
  129.     {
  130.         Close( rexxmsg->rm_Stdout );
  131.         rexxmsg->rm_Stdout = NULL;
  132.     }
  133. }
  134.  
  135.